﻿<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

$editor = &JFactory::getEditor();
JFilterOutput::objectHTMLSafe( $this->item );
JHTML::_('behavior.calendar');
$document	=& JFactory::getDocument();
$link = JRoute::_( 'index.php?option=com_ecommerce&controller=products&task=delete_img&id='. $this->product->id );
?>
<script language="javascript">
function checkname(){
	if($('task').value!="cancel"){
		if (document.adminForm.name.value == ''){
			alert('Không thể để trống tên sản phẩm');
			return false;
		}
	}
	
}
</script>
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
  <div class="col100">
  <fieldset class="adminform">
  <legend><?php echo JText::_( 'Manage product information' ); ?></legend>
  <table class="admintable" style="float:left; width:50%;">
  	<tr>
      <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Number' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="number" id="number" size="20" maxlength="250" value="<?php echo $this->product->number;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Product name' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="name" id="name" size="50" maxlength="250" value="<?php echo htmlspecialchars($this->product->name);?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Type' ); ?>: </label>
      </td>
      <td>
      <?php $arrType = explode(",", $this->product->type);?>
      <input type="checkbox" name="type[1]" id="type" <?php if(in_array(1, $arrType)) echo 'checked="checked"';?> /> <img src="../images/1.png" />
      <input type="checkbox" name="type[2]" id="type" <?php if(in_array(2, $arrType)) echo 'checked="checked"';?> /> <img src="../images/2.png" />
      <input type="checkbox" name="type[3]" id="type" <?php if(in_array(3, $arrType)) echo 'checked="checked"';?> /> <img src="../images/3.png" />
      <input type="checkbox" name="type[4]" id="type" <?php if(in_array(4, $arrType)) echo 'checked="checked"';?> /> <img src="../images/4.png" />
      <input type="checkbox" name="type[5]" id="type" <?php if(in_array(5, $arrType)) echo 'checked="checked"';?> /> <img src="../images/5.png" />
      <input type="checkbox" name="type[6]" id="type" <?php if(in_array(6, $arrType)) echo 'checked="checked"';?> /> <img src="../images/6.png" />
      <input type="checkbox" name="type[7]" id="type" <?php if(in_array(7, $arrType)) echo 'checked="checked"';?> /> <img src="../images/7.png" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="code bar"> <?php echo JText::_( 'Price' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="price" id="price" size="32" maxlength="250" value="<?php echo $this->product->price;?>" /> DKK
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="code bar"> <?php echo JText::_( 'Quantity' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="quantity" id="quantity" size="32" maxlength="250" value="<?php echo $this->product->quantity;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Category' ); ?>: </label>
      </td>
      <td><select name="cat_id[]" multiple="multiple" size="10">
          <option value="0">--Select category--</option>
            <?php echo $this->catoption; ?>
         
        </select>
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Manufacturer' ); ?>: </label>
      </td>
      <td><select name="manufacturer" id="manufacturer">
          <option value='0'>--Select a manufacturer--</option>
          <?php
				$db =& JFactory::getDBO();
				$query = "select * from #__pr_company where published=1";
				$db->setQuery($query);
				if($rows = $db->loadObjectList()){
					foreach($rows as $row){
						if($this->product->manufacturer == $row->id){
							echo "<option selected='selected' value='".$row->id."'>".$row->name."</option>";
						} else {
							echo "<option value='".$row->id."'>".$row->name."</option>";
						}
					}
				}
			?>
        </select>
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Unit' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="unit" id="unit" size="32" maxlength="250" value="<?php echo $this->product->unit;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Unit/parcel' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="parcel" id="parcel" size="32" maxlength="250" value="<?php echo $this->product->parcel;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Origin' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="origin" id="origin" size="32" maxlength="250" value="<?php echo $this->product->origin;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Country' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="country" id="country" size="32" maxlength="250" value="<?php echo $this->product->country;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="desc_on_link"> <?php echo JText::_( 'Expiry' ); ?>: </label>
      </td>
      <td><input class="text_area" type="text" name="expiry" id="expiry" size="32" maxlength="250" value="<?php echo $this->product->expiry;?>" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key">Image:</td>
      <td><?php if(trim($this->product->image)): ?>
        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$this->product->image."&w=100&zc=1' title='".$this->product->name."' alt='".$this->product->name ."' align='middle' />";?>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="<?php echo $link;?>"><img src="images/publish_x.png" align="absmiddle" />Delete</a>
		<?php endif;?>
		<input type="hidden" name="image" value="<?php echo $this->product->image; ?>" /></td>
    </tr>
    <tr>
      <td align="right" class="key"><label for="imagefile"> <?php echo JText::_( 'Upload Image ' ); ?>: </label>
      </td>
      <td><input type="file" name="txtimage" id="txtimage" size="32"  value="" />
      </td>
    </tr>
    <tr>
      <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Ingredients' ); ?>: </label>
      </td>
      <td><?php echo $editor->display( 'ingredient', $this->product->ingredient , '100%', '250', '75', '20' ) ; ?>
      </td>
    </tr>   
  </table>
	 <table class="admintable" style="width:50%">
		<tr>
          <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Basic Information' ); ?>: </label>
          </td>
          <td><?php echo $editor->display( 'basic_info', $this->product->basic_info , '100%', '150', '75', '20' ) ; ?>
          </td>
        </tr>
         <tr>
          <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Instruction' ); ?>: </label>
          </td>
          <td><?php echo $editor->display( 'instruction', $this->product->instruction , '100%', '150', '75', '20' ) ; ?>
          </td>
        </tr>
         <tr>
          <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Description' ); ?>: </label>
          </td>
          <td><?php echo $editor->display( 'description', $this->product->description , '100%', '150', '75', '20' ) ; ?>
          </td>
        </tr>
        <tr>
          <td width="200" align="right" class="key"><label for="title_on_link"> <?php echo JText::_( 'Allergen' ); ?>: </label>
          </td>
          <td><?php echo $editor->display( 'allergen', $this->product->allergen , '100%', '150', '75', '20' ) ; ?>
          </td>
        </tr>
    </table>
  </fieldset>
  </div>
  <div class="clr"></div>
  <input type="hidden" name="option" value="com_ecommerce" />
  <input type="hidden" name="id" value="<?php echo $this->product->id; ?>" />
  <input type="hidden" name="task" id="task" value="" />
  <input type="hidden" name="published" value="1" />
  <input type="hidden" name="controller" value="products" />
</form>
